package com.mes.schedule.domain;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

import org.hibernate.annotations.BatchSize;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.ForeignKey;
import org.hibernate.annotations.JoinColumnOrFormula;
import org.hibernate.annotations.JoinColumnsOrFormulas;
import org.springframework.context.annotation.Lazy;

import com.mes.common.domain.BasicModel;
import com.mes.task.domain.Demand;



/**
 * <p>
 * TaskLink实体，记录指令与任务之间的关系。
 * </p>
 * 
 * <p>
 * Created on 2017-03-11
 * </p>
 * 
 * @author lcs
 */
//@Entity()
@org.hibernate.annotations.Entity(dynamicInsert=true,dynamicUpdate=true)
//@Table(name = "T_SCHEDULE_DEMANDTASKLINK")
@BatchSize(size=20)
@Lazy(value=true)
@Cache(usage=CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class DemandSTaskLink extends BasicModel {
	/**
	 *  已锁定
	 */
	public final static int LOCKLEVEL_LOCKED = 1; 
	/**
	 *  未锁定
	 */
	public final static int LOCKLEVEL_UNLOCKED = 0; 
	/**
	 *  生效
	 */
	public final static int ISINEFFECT_IS = 1; 
	/**
	 *  未生效
	 */
	public final static int ISINEFFECT_ISNOT = 0; 
	
	@Column(name="SCHEDULEUID",length=50)
	protected String scheduleUid;
	
	@Column(name="DEMANDUID",length=50)
	protected String demandUid;
	
	/**
	 * 复杂对象映射
	 * many-to-one
	 */
	@ForeignKey(name="null")
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="DEMANDUID",insertable=false,updatable=false)
	protected Demand demand;

	@Column(name="TASKUID",length=50)
	protected String partTaskUid;
	
	/**
	 * 复杂对象映射
	 * many-to-one
	 */
	@ForeignKey(name="null")
	@ManyToOne(fetch=FetchType.EAGER)
	@JoinColumnsOrFormulas(value={
			@JoinColumnOrFormula(column=@JoinColumn(name="SCHEDULEUID",referencedColumnName="DEMANDUID",nullable=true,insertable=false,updatable=false)),
			@JoinColumnOrFormula(column=@JoinColumn(name="TASKUID",referencedColumnName="TASKUID",nullable=true,insertable=false,updatable=false))
	})
	protected SPartTask partTask;

	@Column(name="LINKQTY",length=50)
	protected Double linkQty;

	protected Double availableQty;

	@Column(name="ISINEFFECT",length=50)
	protected Integer isInEffect;

	@Column(name="DEPENDTYPE",length=50)
	protected String dependType;

	@Column(name="LOCKLEVEL",length=50)
	protected Integer lockLevel;

	@Column(name="LOCKEXPIREDATE",length=50)
	protected Date lockExpireDate;

	/**
	 * 空的构造函数
	 */
	public DemandSTaskLink() {

	}

	public String getDemandUid() {
		return demandUid;
	}

	public void setDemandUid(String demandUid) {
		this.demandUid = demandUid;
	}

	public Demand getDemand() {
		return demand;
	}

	public void setDemand(Demand demand) {
		this.demand = demand;
	}

	public String getPartTaskUid() {
		return partTaskUid;
	}

	public void setPartTaskUid(String partTaskUid) {
		this.partTaskUid = partTaskUid;
	}



	public Double getLinkQty() {
		return linkQty;
	}

	public void setLinkQty(Double linkQty) {
		this.linkQty = linkQty;
	}

	public Integer getIsInEffect() {
		return isInEffect;
	}

	public void setIsInEffect(Integer isInEffect) {
		this.isInEffect = isInEffect;
	}

	public Integer getLockLevel() {
		return lockLevel;
	}

	public void setLockLevel(Integer lockLevel) {
		this.lockLevel = lockLevel;
	}

	public Date getLockExpireDate() {
		return lockExpireDate;
	}

	public void setLockExpireDate(Date lockExpireDate) {
		this.lockExpireDate = lockExpireDate;
	}

	public String getDependType() {
		return dependType;
	}

	public void setDependType(String dependType) {
		this.dependType = dependType;
	}

	public Double getAvailableQty() {
		return availableQty;
	}

	public void setAvailableQty(Double availableQty) {
		this.availableQty = availableQty;
	}

	public String getScheduleUid() {
		return scheduleUid;
	}

	public void setScheduleUid(String scheduleUid) {
		this.scheduleUid = scheduleUid;
	}

	public SPartTask getPartTask() {
		return partTask;
	}

	public void setPartTask(SPartTask partTask) {
		this.partTask = partTask;
	}



}